package exactSearch;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintStream;

public class Matches {

	static PrintStream ps;

	public static void main(String[] args) throws IOException {

		FileReader ff = new FileReader(
				"J:\\BC3_IMT_Training\\annotations\\IMT_training_pmids.txt");

		BufferedReader fb = new BufferedReader(ff);
		String name = fb.readLine();

		ps = new PrintStream("J:\\BC3_IMT_Training\\FOUND.txt");
		while (name != null) {

			FileReader dfr = new FileReader("J:\\BC3_IMT_Training\\PSIMI.txt");
			BufferedReader dfbr = new BufferedReader(dfr);
			String f = dfbr.readLine();

		while (f != null) {
				String dict = f.substring(9);
				String did = f.substring(0, 7);
				//System.out.println(dict);

				FileReader fr = new FileReader(
						"J:\\BC3_IMT_Training\\newtxt\\" + name + ".txt");
				BufferedReader fbr = new BufferedReader(fr);
				String str = fbr.readLine();
				while (str != null) {
					
					int ind=str.indexOf(dict); 
					if (ind!= -1) {
				
							ps.println(name + "\t" + did);
							System.out.println(name + "\t" + did);
						
					}

					str = fbr.readLine();
					
				}
	
				f = dfbr.readLine();
					
			}
			
				System.out.println(name);
			name=fb.readLine();
		}
	}

}
